#region " LICENSE "
// DRILL - Dependency Resolution Interface Layer Library
// Copyright (c) 2008-2012 Wade A. Reynolds. All rights reserved.
// http://drill.codeplex.com/
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#endregion
using System;
using System.Diagnostics;
using System.IO;
using Drill.Configuration;
using Drill.TestSupport;
using Drill.TestSupport.TestDomains.SimpleDomain;
using NUnit.Framework;

namespace Drill
{
	[TestFixture]
	public class DependencyResolverManagerTests
	{
		[Category("UnitTest")]
		[Test]
		public void CanCreateWithConfigurationObject()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();

			// Act
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);

			// Assert
			Assert.That(dependencyResolver, Is.Not.Null);
		}

		[Category("UnitTest")]
		[Test]
		public void CanCreateAndRegisterWithConfigurationObject()
		{
			// Arrange
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);

			// Act
			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];

			// Assert
			Assert.That(DependencyResolverManager.Resolvers.ContainsKey(name), Is.True);
			Assert.That(dependencyResolver, Is.Not.Null);
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateWithNullConfigurationObject()
		{
			// Arrange
			DependencyResolverConfiguration config = null;
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Create(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentException), ExpectedMessage = "initContext.DrillBits property is null or empty", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateWithConfigurationObjectWithNoProviderConfig()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			config.DrillBits.Clear(); // <-- No DrillBits + default dependency resolver (DrillChuck) == exception
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Create(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(FileNotFoundException), ExpectedMessage = "Could not load file or assembly", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateWithInvalidConfigurationObject()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			((DrillBitConfiguration) config.DrillBits[0]).Type = "Test.InvalidTypeName, Test.InvalidAssemblyName";
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Create(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentException), ExpectedMessage = "The value of the config parameter's Name property is null, empty or whitespace", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateAndRegisterWithNullName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			config.Name = null;
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.CreateAndRegister(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentException), ExpectedMessage = "The value of the config parameter's Name property is null, empty or whitespace", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateAndRegisterWithEmptyName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			config.Name = string.Empty;
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.CreateAndRegister(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentException), ExpectedMessage = "The value of the config parameter's Name property is null, empty or whitespace", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateAndRegisterWithWhitespaceName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			config.Name = "   ";
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.CreateAndRegister(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(DependencyResolverException), ExpectedMessage = "is already registered", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateAndRegisterWhenNameIsAlreadyRegistered()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.CreateAndRegister(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotCreateAndRegisterWithNullConfigurationObject()
		{
			// Arrange
			DependencyResolverConfiguration config = null;
			DependencyResolverManager.Reset();

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.CreateAndRegister(config);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[Test]
		public void CanRegister()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);
			string name = config.Name;

			// Act
			DependencyResolverManager.Register(name, dependencyResolver);
			bool isRegistered = DependencyResolverManager.IsRegistered(name);

			// Assert
			Assert.That(isRegistered, Is.True);
			Assert.That(DependencyResolverManager.Resolvers.Count, Is.EqualTo(1));
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotRegisterWithNullName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);
			string name = null;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Register(name, dependencyResolver);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotRegisterWithEmptyName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);
			string name = string.Empty;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Register(name, dependencyResolver);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotRegisterWithWhitespaceName()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);
			const string name = "   ";

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Register(name, dependencyResolver);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(DependencyResolverException), ExpectedMessage = "is already registered", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotRegisterWhenNameIsAlreadyRegistered()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);
			string name = config.Name;
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Register(name, dependencyResolver);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotRegisterWithNullDependencyResolver()
		{
			// Arrange
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = null;
			const string name = "Default";

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.Register(name, dependencyResolver);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[Test]
		public void CanReset()
		{
			// Arrange
			// Noting to arrange.

			// Act
			DependencyResolverManager.Reset();
			var itemUnderTest = DependencyResolverManager.Resolvers;

			// Assert
			Assert.That(itemUnderTest, Is.Not.Null);
			Assert.That(itemUnderTest, Is.Empty);
		}

		[Category("UnitTest")]
		[Test]
		public void CanUnregisterDependencyResolver()
		{
			// Arrange
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);
			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];

			// Verify Arrangement
			Assert.That(DependencyResolverManager.Resolvers.ContainsKey(name), Is.True);
			Assert.That(dependencyResolver, Is.Not.Null);

			// Act
			DependencyResolverManager.Unregister(name);

			// Assert
			Assert.That(DependencyResolverManager.Resolvers, Is.Empty);
		}

		[Category("UnitTest")]
		[Test]
		public void CannotUnregisterDependencyResolverWhenNameIsNull()
		{
			// Arrange
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);
			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];

			// Verify Arrangement
			Assert.That(DependencyResolverManager.Resolvers.ContainsKey(name), Is.True);
			Assert.That(dependencyResolver, Is.Not.Null);

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			string nameToRemove = null;
			DependencyResolverManager.Unregister(nameToRemove);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing should occur. No exception and no change to the registered resolvers.
			Assert.That(DependencyResolverManager.Resolvers.Count, Is.EqualTo(1));
		}

		[Category("UnitTest")]
		[Test]
		public void CannotUnregisterDependencyResolverWhenNameIsEmpty()
		{
			// Arrange
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);
			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];

			// Verify Arrangement
			Assert.That(DependencyResolverManager.Resolvers.ContainsKey(name), Is.True);
			Assert.That(dependencyResolver, Is.Not.Null);

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			string nameToRemove = string.Empty;
			DependencyResolverManager.Unregister(nameToRemove);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing should occur. No exception and no change to the registered resolvers.
			Assert.That(DependencyResolverManager.Resolvers.Count, Is.EqualTo(1));
		}

		[Category("UnitTest")]
		[Test]
		public void CannotUnregisterDependencyResolverWhenNameIsWhitespace()
		{
			// Arrange
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);
			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];

			// Verify Arrangement
			Assert.That(DependencyResolverManager.Resolvers.ContainsKey(name), Is.True);
			Assert.That(dependencyResolver, Is.Not.Null);

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			const string nameToRemove = "  ";
			DependencyResolverManager.Unregister(nameToRemove);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing should occur. No exception and no change to the registered resolvers.
			Assert.That(DependencyResolverManager.Resolvers.Count, Is.EqualTo(1));
		}

		[Category("UnitTest")]
		[Test]
		public void CanInvokeIsRegisteredSuccessfully()
		{
			// Arrange
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			IDependencyResolver dependencyResolver = DependencyResolverManager.Create(config);
			string name = config.Name;

			// Act
			bool isRegistered1 = DependencyResolverManager.IsRegistered(name);
			DependencyResolverManager.Register(name, dependencyResolver);
			bool isRegistered2 = DependencyResolverManager.IsRegistered(name);

			// Assert
			Assert.That(isRegistered1, Is.False);
			Assert.That(isRegistered2, Is.True);
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeIsRegisteredWhenNameIsNull()
		{
			// Arrange
			DependencyResolverManager.Reset();
			string name = null;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.IsRegistered(name);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeIsRegisteredWhenNameIsEmpty()
		{
			// Arrange
			DependencyResolverManager.Reset();
			string name = string.Empty;

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.IsRegistered(name);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[ExpectedException(typeof(ArgumentNullException), ExpectedMessage = "name", MatchType = MessageMatch.Contains)]
		[Test]
		public void CannotInvokeIsRegisteredWhenNameIsWhitespace()
		{
			// Arrange
			DependencyResolverManager.Reset();
			const string name = "\t";

			// Act
			// ReSharper disable ExpressionIsAlwaysNull
			DependencyResolverManager.IsRegistered(name);
			// ReSharper restore ExpressionIsAlwaysNull

			// Assert
			// Nothing to assert because the test should throw an expected exception (see ExpectedException attribute).
		}

		[Category("UnitTest")]
		[Test]
		public void ResolversPropertyIsNotNull()
		{
			// Arrange
			DependencyResolverManager.Reset();

			// Act
			var itemUnderTest = DependencyResolverManager.Resolvers;

			// Assert
			Assert.That(itemUnderTest, Is.Not.Null);
		}

		[Category("IntegrationTest")]
		[Test]
		public void TestDependencyResolverManagerAndDependencyResolver()
		{
			const string name = "Default";
			DependencyResolverConfiguration config = TestConfigs.CreateBasicDependencyResolverConfigurationWithUnityDrillBit();
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);

			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];
			Assert.That(dependencyResolver, Is.Not.Null);

			//--------------------------------------------------------------
			// Act
			ITestObjA testObjA = dependencyResolver.GetInstance<ITestObjA>();

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.AssignableFrom<TestObjA>());

			//--------------------------------------------------------------
			// Act
			testObjA = dependencyResolver.GetInstance(typeof(ITestObjA)) as ITestObjA;

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.AssignableFrom<TestObjA>());

			//--------------------------------------------------------------
			// Act
			ITestObjB testObjB = dependencyResolver.GetInstance<ITestObjB>();

			// Assert
			Assert.That(testObjB, Is.Not.Null);
			Assert.That(testObjB, Is.AssignableFrom<TestObjBWrapper>());

			//--------------------------------------------------------------
			// Act
			testObjB = dependencyResolver.GetInstance(typeof(ITestObjB)) as ITestObjB;

			// Assert
			Assert.That(testObjB, Is.Not.Null);
			Assert.That(testObjB, Is.AssignableFrom<TestObjBWrapper>());

			//--------------------------------------------------------------
			// Act
			ITestObjB myObjB = dependencyResolver.GetInstance<ITestObjB>("MyObjB");

			// Assert
			Assert.That(myObjB, Is.Not.Null);
			Assert.That(myObjB, Is.AssignableFrom<TestObjB>());

			//--------------------------------------------------------------
			// Act
			myObjB = dependencyResolver.GetInstance(typeof(ITestObjB), "MyObjB") as ITestObjB;

			// Assert
			Assert.That(myObjB, Is.Not.Null);
			Assert.That(myObjB, Is.AssignableFrom<TestObjB>());

			DependencyResolverManager.Reset();
		}

		[Category("IntegrationTest")]
		[Test]
		public void TestDependencyResolverManagerAndDependencyResolverWithTestAlternateAppConfig()
		{
			const string name = "Default";
			string configDir = Path.GetDirectoryName(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
			Debug.Assert(configDir != null, "configDir != null");
			string filename = Path.Combine(configDir, "TestAlternateAppConfig.xml");
			IDependencyResolverConfiguration config = ConfigurationLoader.LoadDependencyResolverConfig(name, filename);
			DependencyResolverManager.Reset();
			DependencyResolverManager.CreateAndRegister(config);

			IDependencyResolver dependencyResolver = DependencyResolverManager.Resolvers[name];
			Assert.That(dependencyResolver, Is.Not.Null);

			//--------------------------------------------------------------
			// Act
			ITestObjA testObjA = dependencyResolver.GetInstance<ITestObjA>();

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.AssignableFrom<TestObjA>());

			//--------------------------------------------------------------
			// Act
			testObjA = dependencyResolver.GetInstance(typeof(ITestObjA)) as ITestObjA;

			// Assert
			Assert.That(testObjA, Is.Not.Null);
			Assert.That(testObjA, Is.AssignableFrom<TestObjA>());

			//--------------------------------------------------------------
			// Act
			ITestObjB testObjB = dependencyResolver.GetInstance<ITestObjB>();

			// Assert
			Assert.That(testObjB, Is.Not.Null);
			Assert.That(testObjB, Is.AssignableFrom<TestObjBWrapper>());

			//--------------------------------------------------------------
			// Act
			testObjB = dependencyResolver.GetInstance(typeof(ITestObjB)) as ITestObjB;

			// Assert
			Assert.That(testObjB, Is.Not.Null);
			Assert.That(testObjB, Is.AssignableFrom<TestObjBWrapper>());

			//--------------------------------------------------------------
			// Act
			ITestObjB myObjB = dependencyResolver.GetInstance<ITestObjB>("MyObjB");

			// Assert
			Assert.That(myObjB, Is.Not.Null);
			Assert.That(myObjB, Is.AssignableFrom<TestObjB>());

			//--------------------------------------------------------------
			// Act
			myObjB = dependencyResolver.GetInstance(typeof(ITestObjB), "MyObjB") as ITestObjB;

			// Assert
			Assert.That(myObjB, Is.Not.Null);
			Assert.That(myObjB, Is.AssignableFrom<TestObjB>());

			DependencyResolverManager.Reset();
		}
	}
}